<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>change_passwd</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css">
    <link rel="stylesheet" type="text/css" href="../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../css/button.css">
    <style type="text/css">
        .btn {
            margin-top: 25%;
        }

        #CancelorCheck {
            margin-top: 40%;
        }

        .space {
            width: 10%;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav">
        <div class="aui-pull-left aui-btn" onclick="backup()">
            <span class="aui-iconfont aui-icon-left"></span>返回
        </div>
        <div class="aui-title">修改密码</div>
    </header>

    <ul class="aui-list aui-form-list">

        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    原密码
                </div>
                <div class="aui-list-item-input">
                    <input id="old_passwd" type="password">
                </div>

            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    新密码
                </div>
                <div class="aui-list-item-input">
                    <input id="new_passwd1" type="password">
                </div>
            </div>
        </li>
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-label">
                    再次输入
                </div>
                <div class="aui-list-item-input">
                    <input id="new_passwd2" type="password">
                </div>
            </div>
        </li>
        <li id="CancelorCheck" class="aui-list-item">
            <div class="aui-list-item-inner aui-list-item-center aui-list-item-btn">
                <div class="aui-btn aui-btn-danger aui-margin-l-5" onclick="backup()">取消</div>
                <div class="space"> </div>
                <div class="aui-btn aui-btn-info aui-margin-r-5" onclick="certain()">确定</div>
            </div>
        </li>


</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function() {

    }
    var oldpassword = document.getElementById("old_passwd");
    var newpassword1 = document.getElementById("new_passwd1");
    var newpassword2 = document.getElementById("new_passwd2");

    function backup() {
        api.closeWin({
            name: 'alterpd'
        });
    }

    function getuserId(ret1) {
        api.ajax({
            url: 'http://222.82.232.219/XSKQ/system/getAppUser.do',
            method: 'post',
        }, function(ret, err) {
            if (ret) {
                ret1(ret.data.userId);
            } else {
                alert(JSON.stringify(err));
                ret1(-1);
            }
        });

    }

    function certain() {
        getuserId(function(ret) {
            var userid = ret;
            if (userid > 0) {
                api.ajax({
                    url: 'http://222.82.232.219/XSKQ/system/resetPasswordAppUser.do',
                    method: 'post',
                    data: {
                        values: {
                            appUserUserId: userid,
                            oldPassword: oldpassword.value,
                            newPassword: newpassword1.value,
                            againPassword: newpassword2.value
                        },
                    }
                }, function(ret, err) {
                    if (ret.success) {
                        alert("修改成功！");
                    } else {
                        alert(JSON.stringify(err));
                    }
                });
            } else {
                alert("访问出错！");
            }
            backup();
        });
    }
</script>

</html>
